package cn.edu.hitsz.core;

import java.util.List;

import populus.core.queue.URLLinkedBlockingQueue;
import populus.core.queue.UrlItem;
/**
 * push all the urls to the queue if it not in
 * 
 * @author mingchen
 *
 */
public class URLPipeLine implements PipeLine {
	
	private final List<UrlItem> urlItems ;
	/**
	 * 
	 * @param urls 
	 * 			urlItems extract from the page
	 */
	public URLPipeLine(List<UrlItem> urls){
		if(urls.equals(null)|| urls.isEmpty()){
			throw new IllegalArgumentException("The List cannot be null");
		}
		this.urlItems = urls;
	}
	/**
	 * The method implements from the interface Pipeline 
	 * which push all the urlItems to the queue
	 * -------check duplicate here -------
	 */
	public void pushToUpstream() {
		for(UrlItem url:this.urlItems){
		try {
			URLLinkedBlockingQueue.linkqueue.put(url);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		}
	}

	
	
}
